<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{log_name} : {log_account_no}</title>
<link rel="shortcut icon" href="{dir_image}favicon.ico">
<link rel="stylesheet" type="text/css" href="{dir_css}Global.css" />
<link rel="stylesheet" type="text/css" href="{dir_css}Popup.css" />
<link rel="stylesheet" type="text/css" href="{dir_css}Dean.css" />
<link rel="stylesheet" type="text/css" href="{dir_css}Registrar.css" />

<script type="text/javascript" src="{dir_js}jquery.min.js"></script>
<script type="text/javascript" src="{dir_js}Global.js"></script>



</head>
<body>
<!-- POPUP -->{page_popup}<!-- POPUP END -->
<!-- TOP HEADER -->{page_header}<!-- TOP HEADER END -->
	<div class="main-content">
	
		<table width="0" border="0" cellspacing="0" cellpadding="0">
			<tr valign="top" align="left">
				<td width="220">
					{reg_sub_menu}
				</td>
				<td width="755">
					<div class="page-sub-content">
						<div class="ann-top-label">{semester_label}</div>
						<input type="hidden" id="sem_linker_id" value="{sem_linker_id}"/>
						<input type="hidden" id="sem_fee_linker_id" value="{sem_fee_linker_id}"/>
						<form method="post" enctype="multipart/form-data" action="" onsubmit="return validateForm()" >
							<table width="" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td height="30" width="150">Fees<span class="required-field">*</span></td>
									<td width="13">:</td>
									<td width="607">
										<select class="checklist-course" name="txtfee" id="txtfee"><option>- - - - Fees - - - -</option>{fees_list}</select>
									</td>
								</tr>
								<tr>
									<td height="32">Amount<span class="required-field">*</span></td>
									<td>:</td>
									<td>Php <input type="text" name="txtamount" id="txtamount" class="course-text-input" value="{txtamount}" onkeypress="return numberDate(event, false);"/></td>
								</tr>
								<tr>
									<td height="32" colspan="2"></td>
									<td><input type="submit" name="subButton" class="submit-input" value="Save"/> <input type="button" onclick="linkNewPage('SemesterFees&cid={course_id}')" class="submit-input" value="Cancel"/></td>
								</tr>
								<tr><td height="15" colspan="3"><div class="subj-td-cols-line"></div></td></tr>
							</table>
						</form>
						
						<div class="fee-amount-listing">
							<div class="fee-amount-listing-label">Fees</div>
							<div id="fee_amount_listing"></div>
						</div>
					
					</div>
				</td>
			</tr>
		</table>
		
	</div>
<!-- FOOTER -->{page_footer}<!-- FOOTER -->
<script type="text/javascript">
	
	$(document).ready(function() {
		feeListing();
		getSemLinkerFee();
	});
	
	function validateForm() {
		if ($('#txtfee').val() == '' &&$('#txtamount').val() == '') {
			alert("Input Error.");
			return false;
		}
	}
	
	function getSemLinkerFee() {
		var SFLID = $('#sem_fee_linker_id').val();
		$.post('request.php', {AJAXPost:'GetSemFeeLinkerID', sem_fee_linker_id:SFLID}, function(r) {
			$('#txtfee').val(r.fee_idFK);
			$('#txtamount').val(r.amount);
		}, 'json');
	}
	
	function feeListing() {
		var fal  = $('#fee_amount_listing');
		var SLID = $('#sem_linker_id').val();
		
		fal.html('');
		$.post('request.php', {AJAXPost:'GetFeeList', sem_linker_id:SLID}, function(res) {
			$.each( res, function( key, value ) {
				if ( value['fee_idFK'] == 1 ) {
					$.post('request.php', {AJAXPost:'GetTotalUnits', sem_linker_id:SLID}, function(res2) {
						$('#tuition_fee_value'+key).html('Tuition Fee (' + res2.total_units + ' units * P ' + value['amount'] + ')');
						var amountTotalUnits = parseFloat(res2.total_units) * parseFloat(value['amount']);
						$('#tuition_fee_amount'+key).html(amountTotalUnits.toFixed()+'.00');
					}, 'json');
					var desc_fee = '<span id="tuition_fee_value'+ key +'"></span>';
					var value_fee = '<span id="tuition_fee_amount'+ key +'"></span>';
				}
				else {
					var desc_fee  = value['fee_desc'];
					var value_fee = value['amount'];
				}
				fal.append('<div class="fee-amount-listing-main">'+
								'<div class="fee-amount-listing-main-img"><img src="{dir_image}icon/pencil.png" width="10" height="10" border="0" onclick="linkNewPage(\'FeesAmount&slid=' + SLID + '&slfid=' + value['sem_fees_linker_idPK'] + '\');"/> <img width="10" height="10" src="{dir_image}icon/close.png" border="0" onclick="deleteFees(\'' + value['sem_fees_linker_idPK'] + '\')"/></div>'+
								'<div class="fee-amount-listing-main-label">' + desc_fee + '</div>'+
								'<div class="fee-amount-listing-main-dot">:</div>'+
								'<div class="fee-amount-listing-main-value"><strong>Php ' + value_fee + '</strong></div>'+
							'</div>');
			});
			
		}, 'json');
	}
	
	function totalUnits(SLID) {
		$.post('request.php', {AJAXPost:'GetTotalUnits', sem_linker_id:SLID}, function(res) {
			return res.total_units
		}, 'json');
		
	}
	
	function deleteFees(SLID) {
		$.post('request.php', {AJAXPost:'DeleteSemesterFeesActive', sem_fees_linker_id:SLID}, function(res) {
			feeListing();
			getSemLinkerFee();
		});
	}
		
</script>
</body>
</html>
